<?php

namespace addons\booking\controller;

use addons\booking\model\StoreUser as StoreUserModel;
use addons\booking\model\Worker as WorkerModel;
use addons\booking\model\Areacity;
use addons\booking\model\WorkerAuth as WorkerAuthModel;

use fast\Tree;
use think\Db;
use think\Session;


class WorkerAuth extends Base
{
    protected $noNeedLogin = ['get_work_experience', 'get_citys'];
    protected $modelValidate = true; //是否开启Validate验证，默认是false关闭状态
    protected $modelSceneValidate = true; //是否开启模型场景验证，默认是false关闭状态


    //提交实名认证
    public function save_auth()
    {
        $user_id = $this->auth->id;
        $real_image = $this->request->param('real_image','');
        $card_front = $this->request->param('card_front','');
        $card_back = $this->request->param('card_back','');

        if(!$real_image)  $this->error('请上传真实照片');
        if(!$card_front)  $this->error('请上传身份证正面');
        if(!$card_back)  $this->error('参数错误');

        $res = WorkerAuthModel::save_auth($user_id,$real_image,$card_front,$card_back);
        if($res['status'] == -1){
            $this->error($res['msg']);
        } else{
            $this->success('提交成功');
        }
    }

    //获取实名认证信息
    public function  get_auth_info()
    {
        $user_id = $this->auth->id;
        $info = WorkerAuthModel::where('user_id',$user_id)->find();
        $this->success('',$info);
    }
}
